package com.learn.springboot3.job;

import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.mail.Mail;
import com.learn.springboot3.jwt.Jwt;
import com.learn.springboot3.pojo.Demo;
import com.learn.springboot3.service.DemonService;
import org.apache.hc.client5.http.classic.methods.HttpPost;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.io.entity.StringEntity;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.net.ssl.SSLSocketFactory;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;

/**
 * ClassName: MailsJob
 * Package: com.learn.springboot3.job
 * Description:
 *
 * @Author jiangCheng
 * @Create 2024/10/18 16:52
 * @Version 1.0
 */
@Component
public class MailsJob implements Job {
    @Autowired
    private DemonService demonService;


    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {

        List<Demo> demos = new ArrayList<>();
        for (int i = 0; i < 500; i++) {
            Demo demo = new Demo();
            demo.setName(RandomUtil.randomString(6));
            demo.setAge(i);
            demos.add(demo);
        }
        demonService.saveBatch(demos);
        String printTime = new SimpleDateFormat("yy-MM-dd HH:mm:ss.SSS").format(new Date());
        System.out.println("PrintWordsJob start at:" + printTime + ", prints: Hello Job-" + new Random().nextInt(100));
   
        
    }



}
